<template>
  <div>
    <QupList :column="3" sep="：" default-value="" label-position="right" label-width="150">
      <QupListItem label="市场名称" :value="ctmMarketDTO.marketName" />
      <QupListItem label="市场类型" :value="ctmMarketDTO.marketType" dict-type-code="TOBE_MARKET_TYPE" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      <QupListItem label="市场属性" :value="ctmMarketDTO.marketNatrue" dict-type-code="MARKET_NATURE" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      <template v-if="innerField">
        <QupListItem label="数据来源" :value="ctmMarketDTO.dataSource" dict-type-code="CTM_MARKET_DATA_FROM" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        <QupListItem label="数据来源描述" :value="ctmMarketDTO.dataSourceMsg" :span="24" />
        <QupListItem label="考核计划" :value="ctmMarketDTO.appraisalPlan" dict-type-code="CTM_APPRAISAL_PLAN" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      </template>
      <QupListItem label="跟进状态维护进度" :value="detail.maintenanceStage" dict-type-code="CTM_MARKET_BUID_WEEK_MAINTENANCE_PROGRESS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      <QupListItem label="周数" :value="weeks[detail.weekNumber]" />
      <QupListItem label="上周进展程度" :value="preWeeklyDetailDTO.progressStage" dict-type-code="CTM_MARKET_BUID_FOLLOW_UP_PROGRESS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      <QupListItem label="本周进展程度" :value="detail.progressStage" dict-type-code="CTM_MARKET_BUID_FOLLOW_UP_PROGRESS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      <QupListItem v-if="isOpenSubbranch" label="是否有合适场地" :value="detail.isSuitableSite" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      <QupListItem v-else-if="ctmMarketDTO.marketType!=='B'" label="是否有意向经销商" :value="detail.isIntendedDealer" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      <QupListItem v-if="[1, '1'].includes(detail.isIntendedDealer)" label="是否与上周意向商家相同" :value="detail.isPreWeekSameDealer" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      <template v-if="showFieldCtr">
        <template v-if="!isOpenSubbranch">
          <QupListItem label="商家姓名" :value="detail.dealerName" />
          <QupListItem label="商家年龄" :value="detail.dealerAge" />
          <QupListItem label="意向等级">
            <Tip>
              <div slot="tip">
                A类：确定与全友合作意向，有合作实力，有合适口岸，可快速签约；<br>
                B类：明确与全友合作意向，但可能资金不足或口岸不达标；<br>
                C类：有明确投资意向，对全友或其他竞品品牌；
              </div>
              <c-dict-range-view :value="detail.intentionLevel" dict-type-code="CTM_INTENTION_LEVEL" domain-code="marketing" app-code="slm" />
            </Tip>
          </QupListItem>
        </template>
        <QupListItem label="是否缴纳保证金/意向金" :value="detail.isPayEarmestMoney" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        <QupListItem label="保证金缴纳时间" :value="detail.payEarmestMoneyTime" />
        <template v-if="!isOpenSubbranch">
          <QupListItem label="现经营品牌/行业资历" :value="detail.industryQualification" :span="24" />
          <QupListItem label="是否到店/公司参观" :value="detail.isArriveShore" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        </template>
        <QupListItem label="预算投入金额" :value="`${detail.budgetedAmount || 0}万`" />
        <QupListItem label="预估面积(㎡)" :value="detail.estimatedArea" />
        <QupListItem v-if="!isOpenSubbranch" label="是否有合适场地" :value="detail.isSuitableSite" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        <QupListItem v-if="[1, '1'].includes(detail.isIntendedDealer)" label="是否与上周场地信息相同" :value="detail.isPreWeekSameSite" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        <QupListItem label="场地详细地址" :value="detail.address" :span="24" />
      </template>
      <QupListItem label="本月是否可测绘" :value="detail.isCurrentMonthMakeMap" dict-type-code="BOOLEANS" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
      <QupListItem label="预计测绘时间" :value="formatDate(detail.estimatedSurveyTime)" />
      <!-- <QupListItem label="预计报图时间" :value="formatDate(detail.estimatedDrawingTime)" /> -->
      <QupListItem label="跟进说明" :value="detail.remark" :span="24" />
      <QupListItem label="客户经理提报时间" :value="detail.submitTime" />
    </QupList>
    <c-title title="最后一次审核记录">
      <QupList :column="1" sep="：" default-value="" label-position="right" label-width="100">
        <QupListItem label="审核结果" :value="ctmShopBuildWeekTaskAduitDTO.aduitStatus" dict-type-code="REVIEW_RESULT" :prop-enum="{domainCode:'marketing',appCode:'slm'}" />
        <QupListItem label="审核意见" :value="ctmShopBuildWeekTaskAduitDTO.aduitFialRemark" :span="24" />
      </QupList>
    </c-title>
    <c-title title="上月最后一次审批结果">
      <QupList :column="1" sep="：" default-value="" label-position="right" label-width="100">
        <QupListItem label="审核结果" :value="preCtmShopBuildWeekTaskAduitDTO.aduitStatus" dict-type-code="REVIEW_RESULT" :prop-enum="{domainCode:'marketing',appCode:'slm'}" :span="24" />
        <QupListItem label="审核意见" :value="preCtmShopBuildWeekTaskAduitDTO.aduitFialRemark" :span="24" />
      </QupList>
    </c-title>
  </div>
</template>
<script>
import { parseTime } from '@/utils'
import Tip from '@/components/Tip'
export default {
  name: 'Week',
  components: {
    Tip
  },
  props: {
    detail: {
      type: Object,
      default: () => ({})
    },
    innerField: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      weeks: {
        1: '第一周',
        2: '第二周',
        3: '第三周',
        4: '第四周',
        5: '第五周',
        6: '第六周'
      }
    }
  },
  computed: {
    ctmMarketDTO() {
      return this.detail.ctmMarketDTO || {}
    },
    ctmShopBuildWeekTaskAduitDTO() {
      return this.detail.ctmShopBuildWeekTaskAduitDTO || {}
    },
    // 增开分店
    isOpenSubbranch() {
      const { marketType, marketNatrue } = this.ctmMarketDTO
      return marketType === 'A' && marketNatrue === 'L'
    },
    // 字段显示控制
    showFieldCtr() {
      return (this.isOpenSubbranch && [1, '1'].includes(this.detail.isSuitableSite)) || (!this.isOpenSubbranch && [1, '1'].includes(this.detail.isIntendedDealer))
    },
    // 上周任务信息
    preWeeklyDetailDTO() {
      return this.detail.preWeeklyDetailDTO || {}
    },
    // 上周任务信息审核信息
    preCtmShopBuildWeekTaskAduitDTO() {
      return this.preWeeklyDetailDTO.ctmShopBuildWeekTaskAduitDTO || {}
    }
  },
  methods: {
    formatDate(v) {
      return parseTime(v, '{y}-{m}-{d}')
    }
  }
}
</script>
